package admin

import (
	_ "embed"
	. "go-caipu/pkg/services/sqlstore/migrator"
)

func AddNoticeMigrations(mg *Migrator) {
	noticeV1 := Table{
		Name: "sys_notice",
		Columns: []*Column{
			{Name: "id", Type: DB_BigInt, IsPrimaryKey: true, IsAutoIncrement: true},
			{Name: "title", Type: DB_NVarchar, Length: 128, Nullable: false},
			{Name: "type", Type: DB_TinyInt, Length: 2, Nullable: false},
			{Name: "terminateTime", Type: DB_DateTime, Length: 6, Nullable: true},
			{Name: "effectiveTime", Type: DB_DateTime, Length: 6, Nullable: true},
			{Name: "noticeScope", Type: DB_Int, Length: 4, Nullable: true},
			{Name: "noticeUsers", Type: DB_Varchar, Length: 600, Nullable: true},
			{Name: "content", Type: DB_NVarchar, Length: 3000, Nullable: true},

			{Name: "create_by", Type: DB_BigInt, Nullable: false},
			{Name: "update_by", Type: DB_BigInt, Nullable: true},
			{Name: "created_at", Type: DB_DateTime, Nullable: false},
			{Name: "updated_at", Type: DB_DateTime, Nullable: true},
		},
		Indices: []*Index{
			{Cols: []string{"title", "type"}, Type: UniqueIndex},
		},
	}

	//create table
	mg.AddMigration("create sys_notice table", NewAddTableMigration(noticeV1))
	//index
	mg.AddMigration("add index Ix_sys_notice_title", NewAddIndexMigration(noticeV1, noticeV1.Indices[0]))

}
